package com.example.mallcoupon.sentinel;

import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

@Component
public class HearderOriginParser implements RequestOriginParser {
	@Override
	public String parseOrigin(HttpServletRequest request) {
		// 1、获取请求头
		String origin = request.getHeader("origin");
		// 2、非空判断
		if (StringUtils.isBlank(origin)){
			origin = "origin";
		}
		return origin;
	}
}
